package com.myx.filter;

import com.myx.pojo.User;
import com.myx.tool.Constant;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebFilter(filterName = "VipTwoFilter",urlPatterns = {"/jsp/pages/vip/*"})
public class VipTwoFilter implements Filter {
    public void destroy() {
        
    }

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
        HttpServletRequest httpServletRequest= (HttpServletRequest) request;
        HttpServletResponse httpServletResponse= (HttpServletResponse) response;
        HttpSession session = httpServletRequest.getSession();
        User loginUser = (User) session.getAttribute(Constant.LOGIN_SESSION);
//        if (loginUser.getUserType() != 12) {
//            httpServletRequest.getRequestDispatcher("/index.jsp").forward(httpServletRequest,httpServletResponse);
//        }
        chain.doFilter(request, response);
    }

    public void init(FilterConfig config) throws ServletException {

    }

}
